#ifndef __UART_DEVICE_H__
#define __UART_DEVICE_H__


#define BAUDRATE_OSR_16MHZ_HIGH_SPEED  16
#define BAUDRATE_OSR_16MHZ  14
#define BAUDRATE_OSR_8MHZ   14
#define BAUDRATE_OSR_4MHZ   13
#define BAUDRATE_OSR_2MHZ   13


typedef enum{
  BAUDRATE_DIV_16MHz_9600   = 118,
  BAUDRATE_DIV_16MHz_19200  = 59,
  BAUDRATE_DIV_16MHz_38400  = 29,
  BAUDRATE_DIV_16MHz_57600  = 19,
  BAUDRATE_DIV_16MHz_115200 = 9,
  BAUDRATE_DIV_16MHz_500000 = 1,
  BAUDRATE_DIV_16MHz_1000000 = 0,
}Baudrate_DIV_16MHz_t;


typedef enum{
  BAUDRATE_DIV_8MHz_9600   = 59,
  BAUDRATE_DIV_8MHz_19200  = 29,
  BAUDRATE_DIV_8MHz_38400  = 14,
  BAUDRATE_DIV_8MHz_57600  = 9,
  BAUDRATE_DIV_8MHz_115200 = 4,
}Baudrate_DIV_8MHz_t;


typedef enum{
  BAUDRATE_DIV_4MHz_9600   = 31,
  BAUDRATE_DIV_4MHz_19200  = 15,
  BAUDRATE_DIV_4MHz_38400  = 7,
}Baudrate_DIV_4MHz_t;

typedef enum{
  BAUDRATE_DIV_2MHz_9600   = 15,
  BAUDRATE_DIV_2MHz_19200  = 7,
  BAUDRATE_DIV_2MHz_38400  = 3,
}Baudrate_DIV_2MHz_t;



typedef enum{
  BAUDRATE_9600 = 0,
  BAUDRATE_19200,
  BAUDRATE_38400,
  BAUDRATE_57600,
  BAUDRATE_115200,
  BAUDRATE_500000,
  BAUDRATE_1000000,
}Baudrate_t;

typedef enum{
  BITSIZE_5BITS = 0,
  BITSIZE_6BITS,
  BITSIZE_7BITS,
  BITSIZE_8BITS,
}BitSize_t;


typedef enum{
  PARITY_NONE = 0,
  PARITY_ODD,
  PARITY_EVEN,
}Parity_t;


typedef enum{
  STOPS_1BITS = 0,
  STOPS_2BITS,
}StopBits_t;


typedef void (*uartRx_cb_func_t)(uint8_t data);
typedef void (*uartTx_cb_func_t)(void);





int8_t UART_Init(Baudrate_t baudRate, BitSize_t bitSize, Parity_t parity,StopBits_t stopBits);
void UART_RegisterIRQ(uartRx_cb_func_t rxDowncallback, uartTx_cb_func_t txDowncallback);
void UART_UnRegisterIRQ(void);
int8_t UART_SendData(uint8_t *buff, uint16_t length);














#endif